package com.ac.scum.log.web.model.server.controller;

import com.ac.common.core.exception.BaseException;
import com.ac.common.core.result.Result;
import com.ac.scum.config.bean.ServerFTPFileConfigEconomy;
import com.ac.scum.log.web.model.server.mapper.ServerFtpFileConfigEconomyMapper;
import com.ac.scum.log.web.utils.user.CurrentUserUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@AllArgsConstructor
@RequestMapping("server_economy")
public class EconomyController {
    private final ServerFtpFileConfigEconomyMapper serverFtpFileConfigEconomyMapper;

    @GetMapping("info")
    public Result<ServerFTPFileConfigEconomy> getInfo() throws BaseException {
        return Result.ok(serverFtpFileConfigEconomyMapper.selectOne(Wrappers.<ServerFTPFileConfigEconomy>lambdaQuery()
                .eq(ServerFTPFileConfigEconomy::getServerId, CurrentUserUtil.getCurrentServerId())));
    }

    @PostMapping("update")
    public Result<Boolean> update(@RequestBody ServerFTPFileConfigEconomy serverFTPFileConfigEconomy) throws BaseException {
//        serverFTPFileConfigEconomy.setServerId(CurrentUserUtil.getCurrentServerId());
//        serverFtpFileConfigEconomyMapper.updateById(serverFTPFileConfigEconomy);
        return Result.ok(Boolean.TRUE);
    }
}
